import Vue from "vue";

import Vuex from "vuex";

import axios from "axios";

Vue.use(Vuex);

const state = {
  count: 0,
  id: 1000,
  movieList: [],
};

const mutations = {
  add(state) {
    state.count++;
  },
  addN(state, { n }) {
    state.count += n;
  },
  getMovieListHandel(state, movieList) {
    state.movieList = movieList;
  },
};

const actions = {
  async getMovieListHandelRequest({ commit }) {
    const re = await axios.get(
      "https://pcw-api.iqiyi.com/search/recommend/list?channel_id=1&data_type=1&mode=11&page_id=2&ret_num=48&session=b9fd987164f6aa47fad266f57dffaa6a"
      
    );
    commit("getMovieListHandel",re.data.data.list)
  },
};

export default new Vuex.Store({
  state,
  mutations,
  actions,
});

// "https://pcw-api.iqiyi.com/search/recommend/list?channel_id=1&data_type=1&mode=11&page_id=2&ret_num=48&session=b9fd987164f6aa47fad266f57dffaa6a"
